Mongo环境搭建配置-客户端

下载安装

https://www.mongodb.com/download-center/community?jmp=nav

客户端连接

新mongo环境 mongo mongodb://127.0.0.1:27017
然后创建账号并授权.
mongo mongodb://nlp:nlp@192.168.1.42:27017

参考:https://www.mongodb.org.cn/tutorial/7.html

1
2
3
show dbs

use `dbName`

Docker整合Prometheus、Grafana监控MongoDB

Docker整合Prometheus、Grafana监控MongoDB

1
2
# 启动 mongodb_exporter 监控mongo
docker run -d --name mongodb_exporter -p 9104:9001 chux0519/mongodb_exporter --mongodb.uri mongodb://192.168.0.103:27017
  • 另一种方式。 先进行镜像编译. {镜像太大太复杂。不建议了}
1
2
git clone git@github.com:dcu/mongodb_exporter.git
docker build -t mongodb_exporter .

问题

另外一些其他监控指标可以后续了解支持.

  1. Prometheus 添加配置
1
2
3
4
5
6
7
8
9
10
# 进入 Prometheus 的容器. 修改配置

docker exec -it prometheus vi /etc/prometheus/prometheus.yml

# 添加一下job
- job_name: 'mongodb'
static_configs:
- targets: ['192.168.0.103:9104']
labels:
instance: mongodb
  1. 检查 是否正常http://localhost:9090/targets
  1. 获取grafana json配置
    https://grafana.com/grafana/dashboards?search=mongo&orderBy=name&direction=asc
    找到适合的仪表盘.

mongodb_replset_member_state

请大家为西银高铁、西部交通辛勤付出的同志们投一票,非常感谢, 请选择马校伟,李全,何俊.